<?php

function get_content_link($alias, $culture = 'en') {
    return url_for('@homepage') . "$culture/" . $alias . '.html';
}

function get_blog_link($alias, $culture = 'en') {
    return url_for('@homepage') . "$culture/blog/" . $alias . '.html';
}

function get_local_image_path($image_file) {
    return sfConfig::get('sf_web_dir') . '/uploads/images/' . $image_file;
}

function get_public_image_path($image_file) {
    return public_path('/uploads/images/') . $image_file;
}

function get_culture_date($date, $culture) {
    if ($culture == 'ar') {
        $date = str_replace('January', 'يناير', $date);
        $date = str_replace('February', 'فبراير', $date);
        $date = str_replace('March', 'مارس', $date);
        $date = str_replace('April', 'أبريل', $date);
        $date = str_replace('May', 'يونيه', $date);
        $date = str_replace('June', 'يوليه', $date);
        $date = str_replace('July', 'يونيو', $date);
        $date = str_replace('August', 'يوليو', $date);
        $date = str_replace('September', 'سبتمبر', $date);
        $date = str_replace('October', 'أكتوبر', $date);
        $date = str_replace('November', 'نوفمبر', $date);
        $date = str_replace('December', 'ديسمبر', $date);
        $date = str_replace(',', '', $date);
    }
    return $date;
}

/**
 *    exmaple
 * 
 *           $email_params = array(
 *               'from' => 'aabusaif@dot.jo'
 *               ,'to' => 'aabusaif@dot.jo'
 *               ,'subject' => 'Account Manager Login Information'
 *           );
 *           
 *           $template_vars = array(
 *                   'username' => $email
 *                  ,'password' => $pass
 *           );
 *              
 *           send_email('account_manager', $email_params, $template_vars);
 * 
 */
function send_email($template, $email_params = array(), $vars = array(), $batch_send = false, $content_type = 'text/plain') {

    //$email_params['to'] = 'aabusaif@ymail.com';
    
    $mailer = sfContext::getInstance()->getController()->getAction('default', 'index')->getMailer();
    $body = get_partial("email/{$template}", $vars);
    $message = $mailer->compose($email_params['from'], $email_params['to'], $email_params['subject']);
    if (isset($email_params['bcc']))
        $message->setBcc($email_params['bcc']);
    $message->setBody($body, $content_type);

    if ($batch_send)
        $mailer->batchSend($message);
    else
        $mailer->send($message);
}

?>